package org.moonshiner.controller.service.impl;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.GrantedAuthorityImpl;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Service;

import org.moonshiner.controller.dao.UserDao;

@Service("assembler")
public class UserAssebmler {

	@Autowired
	private UserDao dao;

	public User buildUser(org.moonshiner.model.user.User user) {
		String role = user.getRole().toString();

		Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
		authorities.add(new GrantedAuthorityImpl(role));
//		authorities.add(new GrantedAuthorityImpl("OWNER"));

		return new User(user.getName(), user.getPassword(), true, true, true,
				true, authorities);

	}

}
